﻿using System;
using System.Drawing;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Windows.Forms;
using System.Xml.Serialization;
using RPGMapa.Controls;
using RPGMapa.Data;
using RPGMapa.Forms;
using RPGMapa.Tools;

namespace RPGMapa
{
    public partial class GUI : Form
    {
        Map mapa;
        BasicTool tool;
        Vector2 lastPos;

        private MapPainter MapCTRL
        {
            get { return mapArea1.Map; }
        }

        public GUI()
        {
            InitializeComponent();
            this.Location = new Point(5, 5);

            mapArea1.MAP_MouseClick += new onMouseClick(MapClick);
            mapArea1.MAP_MouseMove += new onMouseMove(MapMove);
            mapArea1.MAP_MouseDown += new onMouseDown(MapDown);
            mapArea1.MAP_MouseUp += new onMouseUp(MapUp);

            this.Show();
            CreateMap();

            tool = new Pencil();
            lastPos = new Vector2(-3, -5); // bem provavel q nunca comecem iguais.
        }



        private void newToolStripButton_Click(object sender, EventArgs e)
        {
            CreateMap();
        }
        private void newToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            CreateMap();
        }
        private void saveToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            SaveMap();
        }
        private void saveToolStripButton_Click(object sender, EventArgs e)
        {
            SaveMap();
        }
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LoadMap();
        }
        private void openToolStripButton_Click(object sender, EventArgs e)
        {
            LoadMap();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            IOdebug d = new IOdebug(MapIO.Encode(mapa));
            d.Show();
            previewBox.Image = mapa.Layer;
        }
        private void importButton_Click(object sender, EventArgs e)
        {
            ImportMap();
        }
        private void exportButton_Click(object sender, EventArgs e)
        {
            ExportMap();
        }

        private void toolStripButton5_Click(object sender, EventArgs e)
        {
            tool = new Pencil();
        }

        private void toolStripButton4_Click(object sender, EventArgs e)
        {
            tool = new Eraser();
        }


    }
}
